home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update29.zoo / include / falcon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-28  |  12.2 KB  |  385 lines

  1. /*
  2.  * GNU-C Bindings for Falcon XBIOS functions
  3.  * -- hyc 11-9-92 (uunet!hanauma.Jpl.Nasa.Gov!hyc)
  4.  */
  5.  
  6. #ifndef _FALCON_H
  7. #define _FALCON_H
  8.  
  9. #ifndef _OSBIND_H
  10. #include <osbind.h>
  11. #endif
  12.  
  13. #ifndef trap_14_wwwwww
  14. #if __GNUC__ > 1
  15. #define trap_14_wwwwww(n,a,b,c,d,e)                    \
  16. __extension__                                \
  17. ({                                    \
  18.     register long retvalue __asm__("d0");                \
  19.     short _a = (short)(a);                        \
  20.     short _b = (short)(b);                        \
  21.     short _c = (short)(c);                        \
  22.     short _d = (short)(d);                        \
  23.     short _e = (short)(e);                        \
  24.                                     \
  25.     __asm__ volatile                        \
  26.     ("\
  27.         movw    %6,sp@-; \
  28.         movw    %5,sp@-; \
  29.         movw    %4,sp@-; \
  30.         movw    %3,sp@-; \
  31.         movw    %2,sp@- "                    \
  32.         movw    %1,sp@-; \
  33.         trap    #14; \
  34.         lea    sp@(12),sp"                    \
  35.     : "=r"(retvalue)                        \
  36.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e)        \
  37.     : "d0", "d1", "d2", "a0", "a1", "a2", "memory");        \
  38.     retvalue;                            \
  39. })
  40. #else
  41. #define trap_14_wwwwww(n,a,b,c,d,e)                    \
  42. ({                                    \
  43.     register long retvalue __asm__("d0");                \
  44.     short _a = (short)(a);                        \
  45.     short _b = (short)(b);                        \
  46.     short _c = (short)(c);                        \
  47.     short _d = (short)(d);                        \
  48.     short _e = (short)(e);                        \
  49.                                     \
  50.     __asm__ volatile                        \
  51.     ("\
  52.         movw    %4,sp@-; \
  53.         movw    %3,sp@-; \
  54.         movw    %2,sp@-; \
  55.         movw    %1,sp@-; \
  56.         movw    %0,sp@- "                    \
  57.     :: "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e));        \
  58.                                     \
  59.     __asm__ volatile                        \
  60.     ("\
  61.         movw    %1,sp@-; \
  62.         trap    #14; \
  63.         lea    sp@(12),sp"                    \
  64.     : "=r"(retvalue)                        \
  65.     : "g"(n)                            \
  66.     : "d0", "d1", "d2", "a0", "a1", "a2");                \
  67.     retvalue;                            \
  68. })
  69. #endif
  70. #endif
  71.  
  72. /*
  73.  * Video
  74.  */
  75.  
  76. /* Video mode codes */
  77.  
  78. #define    VERTFLAG    0x100    /* double-line on VGA, interlace on ST/TV */
  79. #define    STMODES        0x080    /* ST compatible */
  80. #define    OVERSCAN    0x040    /* Multiply X&Y rez by 1.2, ignored on VGA */
  81. #define    PAL        0x020    /* PAL if set, else NTSC */
  82. #define    VGA        0x010    /* VGA if set, else TV mode */
  83. #define    COL80        0x008    /* 80 column if set, else 40 column */
  84. #define    NUMCOLS        7    /* Mask for number of bits per pixel */
  85. #define    BPS16        4
  86. #define    BPS8        3
  87. #define    BPS4        2
  88. #define    BPS2        1
  89. #define    BPS1        0
  90.  
  91. /* Montype return values */
  92. enum montypes {STmono=0, STcolor, VGAcolor, TVcolor};
  93.  
  94. /* VsetSync flags - 0=internal, 1=external */
  95.  
  96. #define    VID_CLOCK    1
  97. #define    VID_VSYNC    2
  98. #define    VID_HSYNC    4
  99.  
  100. #undef Setscreen
  101. #define Setscreen(lscrn,pscrn,rez,mode)                    \
  102.     (short)trap_14_wllww((short)5,(long)(lscrn),(long)(pscrn),    \
  103.         (short)(rez),(short)(mode))
  104. #define Vsetmode(mode)                            \
  105.     (short)trap_14_ww((short)88,(short)(mode))
  106. #define Montype()                            \
  107.     (short)trap_14_w((short)89)
  108. #define    VgetSize(mode)                            \
  109.     (long)trap_14_ww((short)91,(short)(mode))
  110. #define    VsetSync(ext)                            \
  111.     (void)trap_14_ww((short)90,(short)(ext))
  112. #define VsetRGB(index,count,array)                    \
  113.     (void)trap_14_wwwl((short)93,(short)(index),(short)(count),    \
  114.         (long *)(array))
  115. #define VgetRGB(index,count,array)                    \
  116.     (void)trap_14_wwwl((short)94,(short)(index),(short)(count),    \
  117.         (long *)(array))
  118. #define VsetMask(andmask,ormask)                    \
  119.     (void)trap_14_www((short)150,(short)(andmask),(short)(ormask))
  120.  
  121. /*
  122.  * Sound
  123.  */
  124.  
  125. /* _SND cookie values */
  126.  
  127. #define SND_PSG        0x01    /* Yamaha PSG */
  128. #define    SND_8BIT    0x02    /* 8 bit DMA stereo */
  129. #define    SND_16BIT    0x04    /* 16 bit CODEC */
  130. #define    SND_DSP        0x08    /* DSP */
  131. #define    SND_MATRIX    0x10    /* Connection Matrix */
  132.  
  133. /* XXX Docs say Falcon shows 0x3f. What does bit 0x20 mean ??? */
  134.  
  135. /*
  136.  * Sound data memory layout - samples are all signed values
  137.  *
  138.  *                 (each char = 1 byte, 2 chars = 1 word)
  139.  * 1 16 bit stereo track:    LLRRLLRRLLRRLLRR
  140.  * 1 8 bit stereo track:    LRLRLRLR  
  141.  * 2 16 bit stereo tracks:    L0R0L1R1L0R0L1R1
  142.  *  etc...
  143.  */
  144.  
  145. /* Setbuffer regions */
  146.  
  147. #define    SR_PLAY        0    /* Set playback registers */
  148. #define    SR_RECORD    1    /* Set record registers */
  149.  
  150. /* Soundcmd Modes */
  151.  
  152. #define LTATTEN        0    /* Left-channel output attenuation */
  153. #define    RTATTEN        1    /* Right channel atten */
  154. #define    LTGAIN        2    /* Left input gain */
  155. #define    RTGAIN        3    /* Right channel gain */
  156.     /* gain and attenuation in 1.5db units, 0x00V0, V:0-15 */
  157. #define    ADDERIN        4    /* Select inputs to adder 0=off, 1=on */
  158. #define    ADCIN        1    /* Input from ADC */
  159. #define    MATIN        2    /* Input from connection matrix */
  160. #define    ADCINPUT    5    /* Select input to ADC, 0=mic, 1=PSG */
  161. #define    ADCRT        1    /* Right channel input */
  162. #define    ADCLT        2    /* Left input */
  163. #define    SETPRESCALE    6    /* Set TT compatibility prescaler */
  164. #define    PREMUTE        0    /* was /1280, now is invalid, mutes */
  165. #define    PRE1280        PREMUTE
  166. #define    PRE640        1    /* divide by 640 */
  167. #define    PRE320        2    /* / 320 */
  168. #define    PRE160        3    /* / 160 */
  169.  
  170. /* Record/Playback modes */
  171.  
  172. #define    STEREO8        0    /* 8 bit stereo */
  173. #define    STEREO16    1    /* 16 bit stereo */
  174. #define    MONO8        2    /* 8 bit mono */
  175.  
  176. /* Record/Playback tracks range from 0 to 3 */
  177.  
  178. /* XXX Doc for Settracks could be clearer. Can we individually set, e.g.,
  179.    tracks 0 & 2 for playback, or must track selections be contiguous? */
  180.  
  181. /* Sound buffer interrupts */
  182.     /* sources */
  183. #define    SI_TIMERA    0    /* Timer A interrupt */
  184. #define    SI_MFPI7    1    /* MFP interrupt 7 */
  185.     /* causes */
  186. #define    SI_NONE        0    /* No interrupts */
  187. #define    SI_PLAY        1    /* Intr at end of play buffer */
  188. #define    SI_RECORD    2    /* Intr at end of record buffer */
  189. #define    SI_BOTH        3    /* Interrupt for either play or record */
  190.  
  191. /* Buffoper flags */
  192.  
  193. #define    SB_PLA_ENA    1    /* Play enable */
  194. #define    SB_PLA_RPT    2    /* Play repeat (continuous loop mode) */
  195. #define    SB_REC_ENA    4    /* Record enable */
  196. #define SB_REC_RPT    8    /* Record repeat */
  197.  
  198. /* Dsptristate - 0=tristate, 1=enable */
  199.  
  200. /* Gpio modes */
  201.  
  202. #define    GPIO_SET    0    /* Set I/O direction, 0=in, 1=out */
  203. #define    GPIO_READ    1    /* Read bits - only 3 bits on gpio */
  204. #define    GPIO_WRITE    2    /* Write gpio data bits */
  205.  
  206. /* Devconnect (connection matrix) source devices */
  207.  
  208. #define    DMAPLAY        0    /* DMA playback */
  209. #define    DSPXMIT        1    /* DSP transmit */
  210. #define    EXTINP        2    /* External input */
  211. #define    ADC        3    /* Microphone/PSG, see Soundcmd(ADCINPUT) */
  212.  
  213. /* Devconnect destination devices, bitmapped */
  214.  
  215. #define    DMAREC        1    /* DMA record */
  216. #define    DSPRECV        2    /* DSP receive */
  217. #define    EXTOUT        4    /* External output */
  218. #define    DAC        8    /* Headphone, internal speaker, monitor */
  219.  
  220. /* Devconnect clock sources */
  221.  
  222. #define    CLK25M        0    /* Internal 25.175 MHz clock */
  223. #define    CLKEXT        1    /* External clock */
  224. #define    CLK32M        2    /* Internal 32 MHz. Invalid for CODEC */
  225.  
  226. /* Devconnect clock prescaler values */
  227.  
  228. /* XXX Doc lists incorrect hz numbers for many of these... */
  229.  
  230. #define CLKOLD        0    /* TT compatible, see Soundcmd(SETPRESCALE) */
  231. #define    CLK50K        1    /* 49170 hz */
  232. #define    CLK33K        2    /* 32780 hz */
  233. #define    CLK25K        3    /* 24585 hz */
  234. #define    CLK20K        4    /* 19668 hz */
  235. #define    CLK16K        5    /* 16390 hz */
  236.         /*    6    (14049 hz) invalid for CODEC */
  237. #define    CLK12K        7    /* 12292 hz */
  238.         /*    8    (10927 hz) invalid for CODEC */
  239. #define    CLK10K        9    /* 9834 hz */
  240.         /*    10    (8940 hz) invalid for CODEC */
  241. #define    CLK8K        11    /* 8195 hz */
  242.         /*    12    (7565 hz) invalid */
  243.         /*    13    (7024 hz) invalid */
  244.         /*    14    (6556 hz) invalid */
  245.         /*    15    (6146 hz) invalid */
  246.  
  247. /* Sndstatus command */
  248.  
  249. #define    SND_CHECK    0    /* Check current status */
  250. #define    SND_RESET    1    /* Reset sound system */
  251.     /*
  252.      * Reset effects: DSP tristated, gain=atten=0, matrix reset,
  253.      * ADDERIN=0, Mode=STEREO8, Play=Record=Monitor tracks=0,
  254.      * interrupts disabled, buffer operation disabled.
  255.      */
  256.  
  257. /* Sndstatus status return */
  258.  
  259. #define    SS_OK        0    /* No errors */
  260. #define    SS_CTRL        1    /* Invalid control field (Data assumed OK) */
  261. #define    SS_SYNC        2    /* Invalid sync format (mutes) */
  262. #define    SS_SCLK        3    /* Serial clock out of valid range (mutes) */
  263.  
  264. #define    SS_RTCLIP    0x10    /* Right channel is clipping */
  265. #define    SS_LTCLIP    0x20    /* Left channel is clipping */
  266.  
  267. /* Structure used by Buffptr */
  268.  
  269. typedef struct SndBufPtr {
  270.     char *play;
  271.     char *record;
  272.     long reserve1;
  273.     long reserve2;
  274. } SndBufPtr;
  275.  
  276. #define Locksnd()                            \
  277.     (long)trap_14_w((short)128)
  278. #define Unlocksnd()                            \
  279.     (long)trap_14_w((short)129)
  280. #define Setbuffer(region,beg,end)                    \
  281.     (long)trap_14_wwll((short)131,(short)(region),(long)(beg),(long)(end))
  282. #define Soundcmd(mode,data)                        \
  283.     (long)trap_14_www((short)130,(short)(mode),(short)(data))
  284. #define Setmode(stereo_mode)                        \
  285.     (long)trap_14_ww((short)132,(short)(stereo_mode))
  286. #define Settracks(play,rec)                        \
  287.     (long)trap_14_www((short)133,(short)(play),(short)(rec))
  288. #define Setmontracks(montrack)                        \
  289.     (long)trap_14_ww((short)134,(short)(montrack))
  290. #define Setinterrupt(src_inter,cause)                    \
  291.     (long)trap_14_www((short)135,(short)(src_inter),        \
  292.         (short)(cause))
  293. #define Buffoper(mode)                            \
  294.     (long)trap_14_ww((short)136,(short)(mode))
  295. #define Dsptristate(dspxmit,dsprec)                    \
  296.     (long)trap_14_www((short)137,(short)(dspxmit),            \
  297.         (short)(dsprec))
  298. #define Gpio(mode,data)                            \
  299.     (long)trap_14_www((short)138,(short)(mode),(short)(data))
  300. #define Devconnect(src,dst,sclk,pre,proto)                \
  301.     (long)trap_14_wwwwww((short)139,(short)(src),(short)(dst),    \
  302.         (short)(sclk),(short)(pre),(short)(proto))
  303. #define Sndstatus(reset)                        \
  304.     (long)trap_14_ww((short)140,(short)(reset))
  305. #define Buffptr(ptr)                            \
  306.     (long)trap_14_wl((short)141,(long)(ptr))
  307.  
  308. /*
  309.  * DSP functions
  310.  *
  311.  * Don't even *think* of trying to use these without the manual!
  312.  */
  313.         
  314. #define    Dsp_DoBlock(data_in,size_in,data_out,size_out)            \
  315.     (void)trap_14_wllll((short)96,(long)(data_in),(long)(size_in),    \
  316.         (long)(data_out),(long)(size_out))
  317. #define    Dsp_BlkHandShake(data_in,size_in,data_out,size_out)        \
  318.     (void)trap_14_wllll((short)97,(long)(data_in),(long)(size_in),    \
  319.         (long)(data_out),(long)(size_out))
  320. #define    Dsp_BlkUnpacked(data_in,size_in,data_out,size_out)        \
  321.     (void)trap_14_wllll((short)98,(long)(data_in),(long)(size_in),    \
  322.         (long)(data_out),(long)(size_out))
  323. #define    Dsp_BlkWords(data_in,size_in,data_out,size_out)            \
  324.     (void)trap_14_wllll((short)123,(long)(data_in),(long)(size_in),    \
  325.         (long)(data_out),(long)(size_out))
  326. #define    Dsp_BlkBytes(data_in,size_in,data_out,size_out)            \
  327.     (void)trap_14_wllll((short)124,(long)(data_in),(long)(size_in),    \
  328.         (long)(data_out),(long)(size_out))
  329. #define    Dsp_MultBlocks(numsend,numrecv,sendblks,recvblks)        \
  330.     (void)trap_14_wllll((short)127,(long)(numsend),(long)(numrecv),    \
  331.         (long)(sendblks),(long)(recvblks))
  332. #define    Dsp_InStream(data_in,blksiz,numblks,blksdone)            \
  333.     (void)trap_14_wllll((short)99,(long)(data_in),(long)(blksiz),    \
  334.         (long)(numblks),(long)(blksdone))
  335. #define    Dsp_OutStream(data_out,blksiz,numblks,blksdone)            \
  336.     (void)trap_14_wllll((short)100,(long)(data_out),(long)(blksiz),    \
  337.         (long)(numblks),(long)(blksdone))
  338. #define    Dsp_IOStream(data_in,data_out,blkisiz,blkosiz,numblks,blksdone)    \
  339.     (void)trap_14_wllllll((short)101,(long)(data_in),(long)(data_out),\
  340.         (long)(blkisiz),(long)(blkosiz),(long)(numblks),    \
  341.         (long)(blksdone))
  342. #define    Dsp_SetVectors(rcvr,xmtr)                    \
  343.     (void)trap_14_wll((short)126,(long)(rcvr),(long)(xmtr))
  344. #define    Dsp_RemoveInterrupts(mask)                    \
  345.     (void)trap_14_ww((short)102,(short)(mask))
  346. #define    Dsp_GetWordSize()    (long)trap_14_w((short)103)
  347. #define    Dsp_Lock()        (long)trap_14_w((short)104)
  348. #define    Dsp_Unlock()        (void)trap_14_w((short)105)
  349. #define    Dsp_Available(xmem,ymem)                    \
  350.     (void)trap_14_wll((short)106,(long)(xmem),(long)(ymem))
  351. #define    Dsp_Reserve(xmem,ymem)                        \
  352.     (void)trap_14_wll((short)107,(long)(xmem),(long)(ymem))
  353. #define    Dsp_LoadProg(file,ability,buffer)                \
  354.     (long)trap_14_wlwl((short)108,(long)(file),(short)(ability),    \
  355.         (long)(buffer))
  356. #define    Dsp_ExecProg(codeptr,codesiz,ability)                \
  357.     (void)trap_14_wllw((short)109,(long)(codeptr),(long)(codesiz),    \
  358.         (short)(ability))
  359. #define    Dsp_ExecBoot(codeptr,codesiz,ability)                \
  360.     (void)trap_14_wllw((short)110,(long)(codeptr),(long)(codesiz),    \
  361.         (short)(ability))
  362. #define    Dsp_LodToBinary(file,codeptr)                    \
  363.     (long)trap_14_wll((short)111,(long)(file),(long)(codeptr))
  364. #define    Dsp_TriggerHC(vector)                        \
  365.     (void)trap_14_ww((short)112,(short)(vector))
  366. #define    Dsp_RequestUniqueAbility()    (long)trap_14_w((short)113)
  367. #define    Dsp_GetProgAbility()        (long)trap_14_w((short)114)
  368. #define    Dsp_FlushSubroutines()        (void)trap_14_w((short)115)
  369. #define    Dsp_LoadSubroutine(ptr,siz,ability)                \
  370.     (long)trap_14_wllw((short)116,(long)(ptr),(long)(siz),        \
  371.         (short)(ability))
  372. #define    Dsp_InqSubrAbility(ability)                    \
  373.     (long)trap_14_ww((short)117,(short)(ability))
  374. #define    Dsp_RunSubroutine(handle)                    \
  375.     (long)trap_14_ww((short)118,(short)(handle))
  376. #define    Dsp_Hf0(flag)                            \
  377.     (long)trap_14_ww((short)119,(short)(flag))
  378. #define    Dsp_Hf1(flag)                            \
  379.     (long)trap_14_ww((short)120,(short)(flag))
  380. #define    Dsp_Hf2()        (long)trap_14_w((short)121)
  381. #define    Dsp_Hf3()        (long)trap_14_w((short)122)
  382. #define    Dsp_HStat()        (char)trap_14_w((short)125)
  383.  
  384. #endif /* _FALCON_H */
  385.